<?php
// +------------------------------------------------------------------
// | cls-captcha [ think captcha, use cache save key-value, does not use session. ]
// | Copyright (c) 2022 All rights reserved.
// | Based on think-captcha, apply to ThinkPHP 6 | 8.
// | Licensed Mulan PSL v2 ( http://license.coscl.org.cn/MulanPSL2 )
// | Author: CLS <422064377>
// | CreateDate: 2024/8/20
// +------------------------------------------------------------------

namespace chleniang\ClsCaptcha;

use think\Route;
use think\Service;

class CaptchaService extends Service
{
    public function boot()
    {
        // Validate::maker(static function ($validate) {
        //     $validate->extend('cls_captcha', static function ($valueArr) {
        //         $storeKey = empty($valueArr['store']) ? null : $valueArr['store'];
        //         return cls_captcha_check($valueArr['key'], $valueArr['value'], $storeKey);
        //     }, ':attribute错误!');
        // });

        $this->registerRoutes(static function (Route $route) {
            $route->get('cls_captcha/[:config]', "\\chleniang\\ClsCaptcha\\CaptchaController@index");
        });
    }
}